package leetcode.simple._previous;

//二叉树是否是镜像对称的
public class SymmetricBinaryTree {

    public boolean isSymmetric(TreeNode root) {
        if (root == null) return true;

        return symmetric(root.left,root.right);
    }

    private boolean symmetric(TreeNode left, TreeNode right) {
        if (left == null && right == null) return true;

        if (left == null || right == null) return false;

        return left.val == right.val && symmetric(left.right,right.left) && symmetric(left.left,right.right);


    }
}
